package com.ftg.learn.springbootmq.topic.service;

import com.ftg.learn.springbootmq.topic.entity.Order;
import com.ftg.learn.springbootmq.topic.producer.TopicProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service

public class OrderService {


    @Autowired
    private TopicProducer topicProducer;

    public void createOrder(Order order) {
        order.setProductId("PRODUCT_" + System.currentTimeMillis());
        topicProducer.sendProductMessage("create", order);
    }

    public void cancelOrder(String productId) {
        topicProducer.sendProductMessage("delete", productId);
    }

    public void updateOrder(Order order) {
        topicProducer.sendProductMessage("update", order);
    }
}



